﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FinanceGoldPointDal.DAL;
using FinanceGoldPointDal.DTO.Filters;
using FinanceGoldPointDal.DTO;

namespace FinanceGoldPointDal.DAL
{
  public class baseDAL : IDisposable
  {

    public FinancialPointDbEntities myDAL { get; set; }

    public baseDAL()
    {
      myDAL = new FinancialPointDbEntities();
    }


    public FinancialPointDbEntities getNewDAL()
    {
      return  new FinancialPointDbEntities();
    }



    public List<SymbolBase> GetSimboliBase(QuoteFilter pFilter)
    {
      using (var dal = getNewDAL())
      {
        return dal.Simboli
          .Where(xx=> 
             (  string.IsNullOrEmpty(pFilter.Location) ? true : xx.Location == pFilter.Location) 
            
            )
          .Select(xx => 
          new SymbolBase()  { Code = xx.Code, Isin = xx.Isin, Location = xx.Location, Name = xx.Name, Types = xx.Types }
          ).ToList();

      }

    }//fM

  
    public void Dispose()
    {
      myDAL.Dispose();
    }
  }
}
